﻿$(document).ready(function () {
	SetCommonExtensions();
});

function SetCommonExtensions() {

	$.fn.showInlineBlock = function () {
		return this.css("display", "inline-block");
	};
}

function ShowHideMaskForm(mode, target) {

	if (mode == "show") {

		$("#mask").css({ width: $("body").outerWidth(false) + "px", height: $("body").outerHeight(false) + "px", opacity: "0.5" }).fadeIn("fast");

		$(target).fadeIn("fast");
	}
	else if (mode == "hide") {

		$("#mask").fadeOut("fast");

		$(target).fadeOut("fast");

		var targetID = "#" + $(target).attr("id");

		var targetInputsSelector = targetID + " " + "input[type=text]" + "," + targetID + " " + "input[type=file]";

		$(targetInputsSelector).val("");
	}
}

function ShowHideLoadingSpinner(mode, target) {

	if (mode == "show") {

		$(target).show();
	}
	else {

		$(target).hide();
	}

}

function GetErrorMsg(textStatus) {

	var errorMsg = "There was an error during your request.Please refresh the page. Cause: ";

	switch (textStatus) {

		case "timeout":
			errorMsg = errorMsg + "request timeout";

			break;

		case "error":
			errorMsg = errorMsg + "error status returned";

			break;

		case "abort":
			errorMsg = errorMsg + "request was aborted";

			break;

		case "parseerror":
			errorMsg = errorMsg + "There was an error parsing your request";

			break;

		default:
			errorMsg = errorMsg + "Unkown error";
	}

	return errorMsg;
}

/* End */